from lxml import etree

# tree = etree.parse('11.html',parser=etree.HTMLParser())
# print(type(tree))


# text = """
# <!DOCTYPE html>
# <html lang="en">
# <head>
#     <meta charset="UTF-8">
#     <title>Title</title>
# </head>
# <body>
# <ul>
#     <li id="li1">li1</li>
#     <li id="li2">li2</li>
#     <li id="li3">li3</li>
# </ul>
# </body>
# </html>
# """
#
#
# tree = etree.fromstring(text,parser=etree.HTMLParser())
# print(type(tree))


text1 = """
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<ul>
    <li id="li1">li1</li>
    <li id="li2">li2</li>
    <li id="li3">li3</li>
</ul>
</body>
</html>
"""


tree = etree.HTML(text1)
print(type(tree))
title = tree.find('head/title')
print(type(title))
print(title.text)
content = tree.findall('body/ul/li')
print(type(content))
for item in content:
    print(item.text)
